Stochastic Matrices
randStochastic
RandomMatrix.randStochastic — FunctionrandStochastic(n; type, norm)n: dimensiontype: defaulttype = 3,3for doubly randStochastic,1for row,2for column stochasticnorm: defaultfalse, if set totrue, the matrix will be normalized by $\sqrt{n}$ (not a typo)
Examples
Generates a 3 by 3 random doubly stochastic matrix
julia> randStochastic(3)
3×3 Matrix{Float64}:
0.132593 0.216041 0.651367
0.484097 0.320777 0.195126
0.261495 0.537825 0.20068Generates a 3 by 3 normalized random column stochastic matrix
julia> randStochastic(3,type=2,norm=true)
3×3 Matrix{Float64}:
0.583396 0.608739 0.732921
0.672821 0.078786 0.302657
0.475834 1.04453 0.696473Some Random Matrix Theory
using Plots, RandomMatrix, LinearAlgebra
N = 500
colors = [:red,:green,:blue,:purple]
@gif for n = (1:50...,51:10:N...,N:-10:51...,50:1...)
randStochastic(n,norm=true)|>eigvals|>x->scatter(x,ratio=1,xlims=(-1.5,1.5),title="Circular Law for Stochastic Matrices",size=(600,600),label = "n = $(n)")
plot!([exp(θ*im) for θ=0:0.01:2pi],label="",lw=3,c=[rand(colors) for _=0:0.01:2pi])
end